package com.example.codegen;

import com.example.utils.CJUtils;

public class SpawnExpression implements Expression {
    public CallExpression callExpression;

    public SpawnExpression(CallExpression callExpression) {
        this.callExpression = callExpression;
        // for CJ let
        for(Variables arg : callExpression.args){
            CJUtils.spawnParamSet.add(arg.toCJ());
        }
    }

    @Override
    public String toJava() {
        return "new Thread(() -> " + callExpression.toJava() + ")";
    }

    @Override
    public String toGo() {
        return callExpression.toGo();
    }

    @Override
    public String toJs() {
        return "new Promise((resolve, reject) => { " + callExpression.toJs() + " })";
    }

    @Override
    public String toCSharp() {
        return "new Thread(() => " + callExpression.toCSharp() + ")";
    }

    @Override
    public String toCJ() {
        return "spawn { => "+ callExpression.toCJ() +" }";
    }
}
